package view.components;

import java.util.HashMap;

import javax.swing.JComboBox;
import javax.swing.JPanel;

import model.Constants;
import model.HostAddress;
import model.Subnet;
import controller.Controller;

/**
 * @author Alexander Müller
 * 
 */
public class SubnetComboBox extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private final JComboBox combo;
	private final HashMap<String, Subnet> map = new HashMap<String, Subnet>();

	public SubnetComboBox() {

		combo = new JComboBox();
		combo.addItem(Constants.EMPTY);

		for (HostAddress element : Controller.getInstance().getHosts()) {
			for (Subnet subnet : element.getSubnetList()) {

				combo.addItem(subnet.getName());
				map.put(subnet.getName(), subnet);

			}
		}
		this.add(combo);

	}

	public JComboBox getBox() {
		return combo;
	}

	public HashMap<String, Subnet> getMap() {
		return map;
	}

}
